/**
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the GPL License, Version 3.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.gnu.org/licenses/lgpl-3.0.txt
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.guardianapis.api.client;

import java.util.Date;
import java.util.List;

import com.guardianapis.api.domain.Format;

public class SearchRequest {

	/*******************************************************************************
	 * Properties
	 *******************************************************************************/

	private String searchString;
	private Date before;
	private Date after;
	private String contentType;
	private Integer count;
	private Integer startPage;
	private List<String> filters;
	private Format format;

	/*******************************************************************************
	 * Constructors
	 *******************************************************************************/

	public SearchRequest() {
		this.format = Format.XML;
	}
	
	public SearchRequest(String pSearchString) {
		this();
		this.searchString = pSearchString;
	}

	public SearchRequest(String pSearchString, List<String> pFilters) {
		this();
		this.searchString = pSearchString;
		this.filters = pFilters;
	}

	public SearchRequest(String pSearchString, int pCount, int pStartPage) {
		this();
		this.searchString = pSearchString;
		this.count = pCount;
		this.startPage = pStartPage;
	}

	public SearchRequest(String pSearchString, List<String> pFilters, int pCount, int pStartPage) {
		this();
		this.searchString = pSearchString;
		this.filters = pFilters;
		this.count = pCount;
		this.startPage = pStartPage;
	}

	public SearchRequest(String pSearchString, Date pAfter, Date pBefore) {
		this();
		this.searchString = pSearchString;
		this.before = pBefore;
		this.after = pAfter;
	}

	public SearchRequest(String pSearchString, List<String> pFilters, Date pAfter, Date pBefore) {
		this();
		this.searchString = pSearchString;
		this.filters = pFilters;
		this.before = pBefore;
		this.after = pAfter;
	}

	public SearchRequest(String pSearchString, Date pAfter, Date pBefore, int pCount, int pStartPage) {
		this();
		this.searchString = pSearchString;
		this.before = pBefore;
		this.after = pAfter;
		this.count = pCount;
		this.startPage = pStartPage;
	}
	
	public SearchRequest(String pSearchString, List<String> pFilters, Date pAfter, Date pBefore, int pCount, int pStartPage) {
		this();
		this.searchString = pSearchString;
		this.filters = pFilters;
		this.before = pBefore;
		this.after = pAfter;
		this.count = pCount;
		this.startPage = pStartPage;
	}

	/*******************************************************************************
	 * Override Object Methods
	 *******************************************************************************/

	/** 
	 * This is the Eclipse generate hashCode method
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((this.after == null) ? 0 : this.after.hashCode());
		result = prime * result
				+ ((this.before == null) ? 0 : this.before.hashCode());
		result = prime
				* result
				+ ((this.contentType == null) ? 0 : this.contentType.hashCode());
		result = prime * result
				+ ((this.count == null) ? 0 : this.count.hashCode());
		result = prime * result
				+ ((this.filters == null) ? 0 : this.filters.hashCode());
		result = prime * result
				+ ((this.format == null) ? 0 : this.format.hashCode());
		result = prime
				* result
				+ ((this.searchString == null) ? 0 : this.searchString
						.hashCode());
		result = prime * result
				+ ((this.startPage == null) ? 0 : this.startPage.hashCode());
		return result;
	}

	/** 
	 * This is the Eclipse generate equals method
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final SearchRequest other = (SearchRequest) obj;
		if (this.after == null) {
			if (other.after != null)
				return false;
		} else if (!this.after.equals(other.after))
			return false;
		if (this.before == null) {
			if (other.before != null)
				return false;
		} else if (!this.before.equals(other.before))
			return false;
		if (this.contentType == null) {
			if (other.contentType != null)
				return false;
		} else if (!this.contentType.equals(other.contentType))
			return false;
		if (this.count == null) {
			if (other.count != null)
				return false;
		} else if (!this.count.equals(other.count))
			return false;
		if (this.filters == null) {
			if (other.filters != null)
				return false;
		} else if (!this.filters.equals(other.filters))
			return false;
		if (this.format == null) {
			if (other.format != null)
				return false;
		} else if (!this.format.equals(other.format))
			return false;
		if (this.searchString == null) {
			if (other.searchString != null)
				return false;
		} else if (!this.searchString.equals(other.searchString))
			return false;
		if (this.startPage == null) {
			if (other.startPage != null)
				return false;
		} else if (!this.startPage.equals(other.startPage))
			return false;
		return true;
	}
	
	/*******************************************************************************
	 * Getters / Setters
	 *******************************************************************************/

	public String getSearchString() {
		return this.searchString;
	}
	
	public void setSearchString(String pSearchString) {
		this.searchString = pSearchString;
	}
	
	public Date getBefore() {
		return this.before;
	}
	
	public void setBefore(Date pBefore) {
		this.before = pBefore;
	}
	
	public Date getAfter() {
		return this.after;
	}
	
	public void setAfter(Date pAfter) {
		this.after = pAfter;
	}
	
	public String getContentType() {
		return this.contentType;
	}
	
	public void setContentType(String pContentType) {
		this.contentType = pContentType;
	}
	
	public Integer getCount() {
		return this.count;
	}
	
	public void setCount(Integer pCount) {
		this.count = pCount;
	}
	
	public Integer getStartPage() {
		return this.startPage;
	}
	
	public void setStartPage(Integer pStartPage) {
		this.startPage = pStartPage;
	}
	
	public List<String> getFilters() {
		return this.filters;
	}
	
	public void setFilters(List<String> pFilters) {
		this.filters = pFilters;
	}

	public Format getFormat() {
		return this.format;
	}

	public void setFormat(Format pFormat) {
		this.format = pFormat;
	}

}
